﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;

namespace OrderService
{
    [DataContract]
    public class Order
    {
        [DataMember]
        public int OrderID
        {
            get;
            set;
        }

        [DataMember]
        public Guid CustomerId
        {
            get;
            set;
        }


        [DataMember]
        public ICollection<Payment> Payments
        {
            get;
            set;
        }

        [DataMember]
        public decimal Amount
        {
            get;
            set;

        }

        [DataMember]
        public bool Processed
        {
            get;
            set;
        }

        public Order()
        {
            Payments = new List<Payment>();
        }

        public Order(int orderId)
            :this()
        {
            OrderID = orderId;
            Amount = 0M;
            Processed = false;
        }

        public void AddPayment(int transactionId, string cardNumber, decimal amount)
        {
            Amount += amount;
            Payments.Add(new Payment(transactionId, cardNumber, amount));
        }
    }
}
